import Vue from "vue";
import Router from "vue-router";
import $ from "@/common/js/axios";
import store from "@/store/index";
// import Message from 'components/message/message';
// import Weui from 'components/weui/weui';
import Index from "components/index/index";

const Home = () =>
    import(/* webpackChunkName: "home */ "components/index/home");
const TestIndex = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/testIndex/testIndex");
const TestType = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/testType/testType");
const TestAns = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/testAns/testAns");
const TestResult = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/testResult/testResult");
const MatchAnalysis = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/matchAnalysis/matchAnalysis");
const MatchJob = () =>
    import(/* webpackChunkName: "module-test" */ "components/testCon/matchJob/matchJob");

const CompanyDetail = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/companyDetail/companyDetail");
const JobDetail = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/jobDetail/jobDetail");
const Search = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/search/search");
const NewSearch = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/search/newSearch");
const SearchSec = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/search/searchSec");
const NewjobDetail = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/jobDetail/newjobDetail");
const JobNotice = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/jobDetail/jobNotice");
const NewcompanyDetail = () =>
    import(/* webpackChunkName: "module-company" */ "components/company/companyDetail/newcompanyDetail");

const PersonResume = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/resume/resume");
const PersonResumeDetail = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/resume/resumeDetail");
const PersonEditResume = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/resume/editResume");
const PersonResumeList = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/resumeList/resumeList");

const PersonBaseInfo = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/baseInfo");
const PersonWorkHistory = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/workHistory");
const PersonEditWork = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/editWork");

const PersonSchoolExper = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/schoolExper");
const PersonEditSchool = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/editSchool");

const PersonPBaseInfo = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/pBaseInfo");
const PersonBaseInfoEdit = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/editBaseInfo");

const PersonOtherInfo = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/otherInfo");
const PersonOtherInfoEdit = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/editotherInfo");

const PersonJobIntent = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/jobIntent");
const PersonJobIntentEdit = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/editJobIntent");
const PersonUploadPic = () =>
    import(/* webpackChunkName: "module-person" */ "components/person/baseInfo/uploadPic");

const PersonUser = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/userMy");
const UserSendlist = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/tdList");
const UserSightList = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/sightList");
const UserCollectList = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/collectList");
const MyNotice = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/mynotice");
const UserResume = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/myresume");
const UserResumeBaseInfo = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/baseInfo");
const UserResumeJobIntent = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/jobIntent");
const UserResumeWorkHistory = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/workHistory");
const UserResumeEditWorkHistory = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/editWorkHistory");
const UserResumeSchoolExper = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/schoolExper");
const UserResumeEditSchoolExper = () =>
    import(/* webpackChunkName: "module-User" */ "components/person/user/resume/editSchoolExper");

Vue.use(Router);

export default new Router({
    // mode: 'history',
    // base: '/dist',
    routes: [
        {
            path: "/",
            redirect: "/index"
        },
        {
            path: "/index",
            name: "index",
            component: Index,
            beforeEnter(to, from, next) {
                if (to.name == "index") {
                    $.get("/grgl/sfyqzdj").then(res => {
                        // 个人信息
                        const userInfo = res.returnData.grjbxx;
                        if (userInfo) {
                            store.commit("SET_USER_INFO", {
                                name: userInfo.xm,
                                sfzhm: userInfo.sfzhm,
                                grbh: userInfo.grbh,
                                sfyjbdj: userInfo.sfyjbdj,
                                sfyqzdj: userInfo.sfyqzdj
                            });
                        }
                        // 轮播标识
                        const flag =
                            res.returnData.sfxsgg == "1" ? true : false; //1显示
                        store.commit("SET_VISIBLE_SWIPER", flag);
                        store.commit(
                            "SET_VISIBLE_SWIPERGO",
                            +res.returnData.sfxsgg
                        );
                        next({
                            name: "home"
                        });
                    });
                } else {
                    next();
                }
            },
            meta: {
                title: "职业介绍服务"
            },
            children: [
                {
                    path: "/home",
                    name: "home",
                    component: Home,
                    meta: {
                        title: "首页"
                    },
                    beforeEnter(to, from, next) {
                        if (from.name !== "newjobDetail") {
                            sessionStorage.setItem("qwgjz", "");
                        }
                        next();
                    }
                },
                {
                    path: "/company/newsearch",
                    name: "newSearch",
                    component: NewSearch,
                    meta: {
                        title: " 职位搜索"
                    },
                    beforeEnter(to, from, next) {
                        if (from.name !== "newjobDetail") {
                            sessionStorage.setItem("qwgjz", "");
                        }
                        next();
                    }
                },
                {
                    path: "/company/searchSec",
                    name: "searchSec",
                    component: SearchSec,
                    meta: {
                        title: "移动传媒"
                    },
                    beforeEnter(to, from, next) {
                        if (from.name !== "newjobDetail") {
                            sessionStorage.setItem("qwgjz", "");
                        }
                        next();
                    }
                },
                {
                    path: "/test/testindex",
                    name: "testindex",
                    component: TestIndex,
                    meta: {
                        title: " 个人职业测评"
                    }
                },
                {
                    path: "/person/user",
                    name: "personUser",
                    component: PersonUser,
                    meta: {
                        title: "我的"
                    }
                }
            ]
        },
        {
            path: "/test/type",
            name: "testType",
            component: TestType,
            meta: {
                title: "个人职业测评"
            }
        },
        {
            path: "/test/ans",
            name: "testAns",
            component: TestAns,
            meta: {
                title: "答题测评"
            }
        },
        {
            path: "/test/result",
            name: "testResult",
            component: TestResult,
            meta: {
                title: "测评结果 "
            }
        },
        {
            path: "/test/matchAnalysis",
            name: "matchAnalysis",
            component: MatchAnalysis,
            meta: {
                title: "匹配分析 "
            }
        },
        {
            path: "/company/companyDetail",
            name: "companyDetail",
            component: CompanyDetail,
            meta: {
                title: "单位详情"
            }
        },
        {
            path: "/company/newcompanyDetail",
            name: "newcompanyDetail",
            component: NewcompanyDetail,
            meta: {
                title: "单位详情"
            }
        },
        {
            path: "/company/jobDetail",
            name: "jobDetail",
            component: JobDetail,
            meta: {
                title: "职位详情"
            }
        },
        {
            path: "/company/newjobDetail",
            name: "newjobDetail",
            component: NewjobDetail,
            meta: {
                title: "职位详情"
            }
        },
        {
            path: "/test/matchJob",
            name: "matchJob",
            component: MatchJob,
            meta: {
                title: "匹配分析"
            }
        },
        {
            path: "/person/resumeList",
            name: "personResumeList",
            component: PersonResumeList,
            meta: {
                title: "个人简历"
            }
        },
        {
            path: "/person/baseInfo",
            name: "personBaseInfo",
            component: PersonBaseInfo,
            meta: {
                title: "基本信息"
            }
        },
        {
            path: "/person/baseInfo/workHistory",
            name: "personWorkHistory",
            component: PersonWorkHistory,
            meta: {
                title: "工作经历"
            }
        },
        {
            path: "/person/baseInfo/editWork",
            name: "personEditWork",
            component: PersonEditWork,
            meta: {
                title: "添加/编辑工作经历"
            }
        },
        {
            path: "/person/baseInfo/pBaseInfo",
            name: "personPBaseInfo",
            component: PersonPBaseInfo,
            meta: {
                title: "个人基本信息"
            }
        },
        {
            path: "/person/baseInfo/edit",
            name: "personBaseInfoEdit",
            component: PersonBaseInfoEdit,
            meta: {
                title: "个人基本信息编辑"
            }
        },
        {
            path: "/person/baseInfo/jobIntent",
            name: "personJobIntent",
            component: PersonJobIntent,
            meta: {
                title: "求职意向"
            }
        },

        {
            path: "/person/baseInfo/jobEdit",
            name: "personJobIntentEdit",
            component: PersonJobIntentEdit,
            meta: {
                title: "求职意向编辑"
            }
        },
        {
            path: "/person/baseInfo/schoolExper",
            name: "personSchoolExper",
            component: PersonSchoolExper,
            meta: {
                title: "学习信息"
            }
        },

        {
            path: "/person/baseInfo/editSchool",
            name: "personEditSchool",
            component: PersonEditSchool,
            meta: {
                title: "编辑学习信息"
            }
        },
        {
            path: "/person/baseInfo/otherInfo",
            name: "personOtherInfo",
            component: PersonOtherInfo,
            meta: {
                title: "编辑其他信息"
            }
        },
        {
            path: "/person/baseInfo/editotherInfo",
            name: "personOtherInfoEdit",
            component: PersonOtherInfoEdit,
            meta: {
                title: "编辑其他信息"
            }
        },
        {
            path: "/person/resume",
            name: "personResume",
            component: PersonResume,
            meta: {
                title: "简历详情"
            }
        },
        {
            path: "/person/resumeDetail",
            name: "personResumeDetail",
            component: PersonResumeDetail,
            meta: {
                title: "简历详显"
            }
        },
        {
            path: "/person/resume/editResume",
            name: "personEditResume",
            component: PersonEditResume,
            meta: {
                title: "简历编辑"
            }
        },
        {
            path: "/company/search",
            name: "search",
            component: Search,
            meta: {
                title: " 职位搜索"
            }
        },
        {
            path: "/person/baseInfo/uploadPic",
            name: "personUploadPic",
            component: PersonUploadPic,
            meta: {
                title: " 图片上传"
            }
        },
        {
            path: "/user/tdList",
            name: "userSendlist",
            component: UserSendlist,
            meta: {
                title: "我的投递"
            }
        },
        {
            path: "/user/sightList",
            name: "UsersightList",
            component: UserSightList,
            meta: {
                title: "我的关注"
            }
        },
        {
            path: "/user/collectList",
            name: "UsercollectList",
            component: UserCollectList,
            meta: {
                title: "我的收藏"
            }
        },
        {
            path: "/user/mynotice",
            name: "Mynotice",
            component: MyNotice,
            meta: {
                title: "我的面试通知"
            }
        },
        {
            path: "/user/resume",
            name: "userResume",
            component: UserResume,
            meta: {
                title: "简历详情"
            }
        },
        {
            path: "/user/resume/baseInfo",
            name: "UserResumeBaseInfo",
            component: UserResumeBaseInfo,
            meta: {
                title: "基本信息编辑"
            }
        },
        {
            path: "/user/resume/jobIntent",
            name: "UserResumejobIntent",
            component: UserResumeJobIntent,
            meta: {
                title: "求职意向"
            }
        },
        {
            path: "/user/resume/workHistory",
            name: "UserResumeworkHistory",
            component: UserResumeWorkHistory,
            meta: {
                title: "工作经历"
            }
        },
        {
            path: "/user/resume/editWorkHistory",
            name: "UserResumeeditWorkHistory",
            component: UserResumeEditWorkHistory,
            meta: {
                title: "工作经历编辑"
            }
        },
        {
            path: "/user/resume/schoolExper",
            name: "UserResumeschoolExper",
            component: UserResumeSchoolExper,
            meta: {
                title: "教育经历"
            }
        },
        {
            path: "/user/resume/editSchoolExper",
            name: "UserResumeeditSchoolExper",
            component: UserResumeEditSchoolExper,
            meta: {
                title: "教育经历编辑"
            }
        }
    ]
});
